package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class DelOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        System.out.println("请输入将要删除的图书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            if(bookList.findBook(i).getName().equals(name)) {
                for (int j = i+1; j < bookList.getUsedSize(); j++) {
                    Book tmp = bookList.findBook(j-1);
                    tmp = bookList.findBook(j);
                }
                bookList.setUsedSize(bookList.getUsedSize()-1);
                System.out.println("删除图书成功");
                return;
            }

        }
        System.out.println("该图书尚未添加...");
        return;
    }
}
